package cn.iocoder.yudao.module.member.convert.config;

import cn.iocoder.yudao.module.member.api.config.dto.MemberConfMaterialDTO;
import cn.iocoder.yudao.module.member.api.config.dto.MemberConfRespDTO;
import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO;
import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigRespVO;
import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserDetailRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.MemberConfDO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confadditionalfee.MemberConfAdditionalFeeDO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confmaterial.MemberConfMaterialDO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confpoint.MemberConfPointDO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confrebate.MemberConfRebateDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 会员配置 Convert
 *
 * @author QingX
 */
@Mapper
public interface MemberConfConvert {

    MemberConfConvert INSTANCE = Mappers.getMapper(MemberConfConvert.class);

    MemberConfigRespVO convert(MemberConfigDO bean);

    MemberConfigDO convert(MemberConfigSaveReqVO bean);

    MemberConfigRespDTO convert01(MemberConfigDO config);

    /**
     * 将会员配置DO和物料列表转换为会员配置响应DTO
     *
     * @param confDO 会员配置DO
     * @param materialDTOList 物料配置列表
     * @return 会员配置响应DTO
     */
    @Mapping(source = "confDO.id", target = "id")
    @Mapping(source = "confDO.userId", target = "userId")
    @Mapping(source = "confDO.physicalMetal", target = "physicalMetal")
    @Mapping(source = "confDO.priceLockBuy", target = "priceLockBuy")
    @Mapping(source = "confDO.priceLockSell", target = "priceLockSell")
    @Mapping(source = "confDO.takeMaterial", target = "takeMaterial")
    @Mapping(source = "confDO.storeMaterial", target = "storeMaterial")
    @Mapping(source = "confDO.autoDispatchOrder", target = "autoDispatchOrder")
    @Mapping(source = "confDO.authIdentity", target = "authIdentity")
    @Mapping(source = "confDO.depositToPoints", target = "depositToPoints")
    @Mapping(source = "confDO.pointsToDeposit", target = "pointsToDeposit")
    @Mapping(source = "confDO.splitDeposit", target = "splitDeposit")
    @Mapping(source = "confDO.splitDepositWithoutReplenish", target = "splitDepositWithoutReplenish")
    @Mapping(source = "confDO.showRiskReport", target = "showRiskReport")
    @Mapping(source = "confDO.autoReminder", target = "autoReminder")
    @Mapping(source = "confDO.loanLimit", target = "loanLimit")
    @Mapping(source = "confDO.settlementMethod", target = "settlementMethod")
    @Mapping(source = "confDO.autoSettlementRatio", target = "autoSettlementRatio")
    @Mapping(source = "confDO.autoDepositRatio", target = "autoDepositRatio")
    @Mapping(source = "confDO.autoDeposit", target = "autoDeposit")
    @Mapping(source = "materialDTOList", target = "confMaterials")
    MemberConfRespDTO convertDTO(MemberConfDO confDO, List<MemberConfMaterialDTO> materialDTOList);
    @Mapping(source = "confDO.id", target = "id")
    @Mapping(source = "confDO.userId", target = "userId")
    @Mapping(source = "confDO.physicalMetal", target = "physicalMetal")
    @Mapping(source = "confDO.priceLockBuy", target = "priceLockBuy")
    @Mapping(source = "confDO.priceLockSell", target = "priceLockSell")
    @Mapping(source = "confDO.takeMaterial", target = "takeMaterial")
    @Mapping(source = "confDO.storeMaterial", target = "storeMaterial")
    @Mapping(source = "confDO.autoDispatchOrder", target = "autoDispatchOrder")
    @Mapping(source = "confDO.authIdentity", target = "authIdentity")
    @Mapping(source = "confDO.depositToPoints", target = "depositToPoints")
    @Mapping(source = "confDO.pointsToDeposit", target = "pointsToDeposit")
    @Mapping(source = "confDO.splitDeposit", target = "splitDeposit")
    @Mapping(source = "confDO.splitDepositWithoutReplenish", target = "splitDepositWithoutReplenish")
    @Mapping(source = "confDO.showRiskReport", target = "showRiskReport")
    @Mapping(source = "confDO.autoReminder", target = "autoReminder")
    @Mapping(source = "confDO.loanLimit", target = "loanLimit")
    @Mapping(source = "confDO.settlementMethod", target = "settlementMethod")
    @Mapping(source = "confDO.autoSettlementRatio", target = "autoSettlementRatio")
    @Mapping(source = "confDO.autoDepositRatio", target = "autoDepositRatio")
    @Mapping(source = "confDO.autoDeposit", target = "autoDeposit")
    MemberConfRespDTO convertDTO(MemberConfDO confDO);

    /**
     * 将物料策略配置及相关的积分配置、返佣配置和附加费配置转换为MaterialDTO
     *
     * @param materialDO 物料策略配置DO
     * @param confPointList 积分配置列表
     * @param confRebateList 返佣配置列表
     * @param confAdditionalFeeList 附加费配置列表
     * @return 物料策略配置DTO
     */
    @Mapping(source = "materialDO.id", target = "id")
    @Mapping(source = "materialDO.memberConfId", target = "memberConfId")
    @Mapping(source = "materialDO.policyType", target = "policyType")
    @Mapping(source = "materialDO.metalType", target = "metalType")
    @Mapping(source = "materialDO.depositWeight", target = "depositWeight")
    @Mapping(source = "materialDO.weightSingleLimit", target = "weightSingleLimit")
    @Mapping(source = "materialDO.weightTotalLimit", target = "weightTotalLimit")
    @Mapping(source = "materialDO.delayFee", target = "delayFee")
    @Mapping(source = "materialDO.processingFee", target = "processingFee")
    @Mapping(source = "materialDO.additionalFee", target = "additionalFee")
    @Mapping(source = "materialDO.interestFreeDays", target = "interestFreeDays")
    @Mapping(source = "materialDO.allowSmallOrder", target = "allowSmallOrder")
    @Mapping(source = "materialDO.auditDepositRatio", target = "auditDepositRatio")
    @Mapping(source = "confPointList", target = "confPoints")
    @Mapping(source = "confRebateList", target = "confRebates")
    @Mapping(source = "confAdditionalFeeList", target = "confAdditionalFees")
    MemberConfMaterialDTO convertMaterialDTO(MemberConfMaterialDO materialDO, List<MemberConfPointDO> confPointList, List<MemberConfRebateDO> confRebateList, List<MemberConfAdditionalFeeDO> confAdditionalFeeList);

    /**
     * 将会员用户DO和会员配置DTO转换为会员详情VO
     *
     * @param userDO 会员用户DO
     * @param memberConfRespVO 会员配置DTO
     * @return 会员详情VO
     */
    @Mapping(source = "userDO.id", target = "id")
    @Mapping(source = "userDO.mobile", target = "mobile")
    @Mapping(source = "userDO.password", target = "password")
    @Mapping(source = "userDO.status", target = "status")
    @Mapping(source = "userDO.type", target = "type")
    @Mapping(source = "userDO.registerIp", target = "registerIp")
    @Mapping(source = "userDO.registerTerminal", target = "registerTerminal")
    @Mapping(source = "userDO.loginIp", target = "loginIp")
    @Mapping(source = "userDO.loginDate", target = "loginDate")
    @Mapping(source = "userDO.nickname", target = "nickname")
    @Mapping(source = "userDO.avatar", target = "avatar")
    @Mapping(source = "userDO.name", target = "name")
    @Mapping(source = "userDO.sex", target = "sex")
    @Mapping(source = "userDO.areaId", target = "areaId")
    @Mapping(source = "userDO.birthday", target = "birthday")
    @Mapping(source = "userDO.mark", target = "mark")
    @Mapping(source = "userDO.point", target = "point")
    @Mapping(source = "userDO.balance", target = "balance")
    @Mapping(source = "userDO.tagIds", target = "tagIds")
    @Mapping(source = "userDO.levelId", target = "levelId")
    @Mapping(source = "userDO.experience", target = "experience")
    @Mapping(source = "userDO.groupId", target = "groupId")
    @Mapping(source = "userDO.payPassword", target = "payPassword")
    @Mapping(source = "userDO.bankMobile", target = "bankMobile")
    @Mapping(source = "userDO.bankId", target = "bankId")
    @Mapping(source = "userDO.identityId", target = "identityId")
    @Mapping(source = "userDO.identityPicFont", target = "identityPicFont")
    @Mapping(source = "userDO.identityPicBack", target = "identityPicBack")
    @Mapping(source = "userDO.bankPic", target = "bankPic")
    @Mapping(source = "userDO.businessLicensePic", target = "businessLicensePic")
    @Mapping(source = "userDO.createTime", target = "createTime")
    @Mapping(source = "memberConfRespVO", target = "memberConf")
    MemberUserDetailRespVO convertRespVO(MemberUserDO userDO, MemberConfRespDTO memberConfRespVO);
}
